import random
import string

def generate_test_cases():
    """生成测试用例"""
    test_cases = []
    
    # 基本测试用例
    basic_cases = [
        "25525511135",
        "0000",
        "1111",
        "010010",
        "101023",
        "256256256256",
        "192168001001",
        "00000",
        "12345",
        "255255255255"
    ]
    
    test_cases.extend(basic_cases)
    
    # 生成随机测试用例
    for _ in range(10):
        # 生成长度为4-12的数字字符串
        length = random.randint(4, 12)
        s = ''.join(random.choices(string.digits, k=length))
        test_cases.append(s)
    
    # 边界情况
    edge_cases = [
        "",  # 空字符串
        "1",  # 太短
        "12",  # 太短
        "123",  # 太短
        "1234",  # 最短有效长度
        "123456789012",  # 最长有效长度
        "1234567890123",  # 太长
    ]
    
    test_cases.extend(edge_cases)
    
    return test_cases

def save_test_cases(filename="test_data.txt"):
    """保存测试用例到文件"""
    test_cases = generate_test_cases()
    
    with open(filename, "w", encoding="utf-8") as f:
        for case in test_cases:
            f.write(f"{case}\n")
    
    print(f"已生成 {len(test_cases)} 个测试用例，保存到 {filename}")
    return test_cases

if __name__ == "__main__":
    test_cases = save_test_cases()
    print("测试用例示例:")
    for i, case in enumerate(test_cases[:10]):
        print(f"{i+1}: '{case}'")
